package com.example.bookstore.entity

import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import org.hibernate.annotations.Fetch
import org.hibernate.annotations.FetchMode
import javax.persistence.*

/**
 * Created by IntelliJ IDEA.
 * User: lvshe
 * Date: 2019/8/8
 * Time: 15:50
 */
@Table
@Entity
class PressEntity : BaseEntity {

    constructor() : super()
    constructor(name: String, imageUrl: String, description: String) : super() {
        this.name = name
        this.imageUrl = imageUrl
        this.description = description
    }


    @Column(nullable = false)
    var name = ""

    @Column(nullable = false)
    var imageUrl = ""

    @Lob
    @Column(nullable = false)
    var description = ""

//    @Fetch(FetchMode.JOIN)
    @OneToMany(mappedBy = "press")
    @JsonIgnoreProperties("press")
    var books: Set<BookEntity> = emptySet()

}